<%-- 
    Document   : index
    Author     : Jagadeesh
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.*" %>
<%@page import="model.Produk" %>
<%@page import="model.Koperasi" %>
<%@page import="database.DBClass"%>
<%@page import="validation.ValidateForm"%>
<%@ page import ="java.sql.*" %>
<%


//    if (request.getAttribute("akun")!="admin"){
//        response.sendRedirect("view.jsp");
//    }
    Produk produk;
    produk = new Produk();
    //get request from servlet if data is invalid
    if (request.getAttribute("error") != null) {
        produk = (Produk) request.getAttribute("error");
    }
    if (request.getAttribute("updateuser") != null) {
        produk = (Produk) request.getAttribute("updateuser");
    }

    if (session.getAttribute("akun") == null) {
        response.sendRedirect(request.getContextPath() + "/admin/login.jsp");
    }
    DBClass dbobject = new DBClass();
    List list = dbobject.getJenis();
    List list1 = dbobject.getAllkoperasi();
%>
<html>
    <head>
        <style type="text/css">
            body {
                background-color:black;
                background-image:url(images/4.jpg); 
            }
        </style>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="<%request.getContextPath();%>/E-Stonion/css/metro-bootstrap.css" rel="stylesheet"> 
        <link href="<%request.getContextPath();%>/E-Stonion/css/metro-bootstrap-responsive.css" rel="stylesheet">

        <script src="<%request.getContextPath();%>/E-Stonion/js/jquery/jquery.min.js"></script>
        <script src="<%request.getContextPath();%>/E-Stonion/js/jquery/jquery.widget.min.js"></script>

        <script src="<%request.getContextPath();%>/E-Stonion/js/metro/metro-*.js"></script>
        <title><%=produk.getAction()%> Page</title>
    </head>
    <body class="metro">
    <nav class="navigation-bar">
        <nav class="navigation-bar-content">
            <a class="element" href="/E-Stonion/home.jsp">
                <span class="icon-grid-view"></span>
                E-Stonion </a>


            <span class="element-divider"></span>
            <a class="element" href="viewproduk">View Produk</a>
            <a class="element" href="insertproduk">Insert Produk</a>
            <a class="element" href="viewkoperasi">View Koperasi</a>
            <a class="element" href="insertkoperasi">Insert Koperasi</a>
            <span class="element-divider"></span>
            <a class="element place-right" href="LoginServlet?action=logout">Logout</a>
            <span class="element-divider place-right"></span>
        </nav>
    </nav> 
  
        <form class="form" method="post" action="<%request.getContextPath();%>/E-Stonion/ControllerServlet">

            <CENTER>
                <TABLE border="0"width="600px">
                    <TR>
                        <TD width="150px">Nama Produk</TD>
                        <TD>:</TD><TD>
                            <INPUT TYPE="text" NAME="namaproduk" value="<%=produk.getnamaproduk()%>">
                        </TD>
                        <TD width="350px">
                            <p class="text-alert"><%=produk.getnamaprodukError()%> &nbsp;</p>
                        </TD>
                    </TR>
                    <TR>
                        <TD width="150px">Harga Produk</TD>
                        <TD>:</TD><TD>
                            <INPUT TYPE="text" NAME="hargaproduk"  value="<%=produk.gethargaproduk()%>">
                        </TD>
                        <TD>
                            <p class="text-alert"><%=produk.gethargaprodukError()%> </p>
                        </TD>
                    </TR>
                    <TR>
                        <TD width="150px">Jenis Produk</TD>
                        <TD>:</TD><TD>

<!--                            <INPUT TYPE="text" NAME="jenisproduk" value="<%=produk.getjenisproduk()%>">-->
                            <select id="jenisproduk" name="jenisproduk">
                                <%
                                    if (list != null) {
                                        for (int i = 0; i < list.size(); i++) {
                                            Produk uproduk = (Produk) list.get(i);

                                %>
                                <option value="<%=uproduk.getjenisambil()%>"><%=uproduk.getjenisambil()%></option>
                                <%
                                        }
                                    }
                                %>
                            </select>
                            <!--                            <script type="text/javascript">
                                                            $(document).ready(function() {
                                                                $("#jenisproduk option[value='Tas']").attr("selected", "selected");
                                                            });
                                                        </script>-->
                        </TD>
                        <TD>
                            <p class="text-alert"><%=produk.getjenisprodukError()%> </p>
                        </TD>
                    </TR>
                    <TR>
                        <TD width="150px">Deskripsi Produk</TD>
                        <TD>:</TD><TD>
                            <textarea name="deskripsiproduk" value="<%=produk.getdeskripsiproduk()%>"><%=produk.getdeskripsiproduk()%></textarea>
                        </TD>
                        <TD>
                            <p class="text-alert"><%=produk.getdeskripsiprodukError()%> </p>
                        </TD>
                    </TR>
                    <TR>
                        <TD width="150px">Letak Produk</TD>
                        <TD>:</TD><TD>
    <!--                            <INPUT TYPE="text" NAME="idkopf" value="<%=produk.getidkopf()%>">-->
                            <select id="idkopf" name="idkopf">
                                <%
                                    if (list1 != null) {
                                        for (int i = 0; i < list1.size(); i++) {
                                            Koperasi uproduk1 = (Koperasi) list1.get(i);

                                %>
                                <option value="<%=uproduk1.getidkoperasi()%>"><%=uproduk1.getnamakoperasi()%></option>
                                <%
                                        }
                                    }
                                %>
                            </select>
                        </TD>
                    </TR>
                    <TR>
                        <TD><INPUT TYPE="hidden" NAME="idproduk" value="<%=produk.getidproduk()%>"></TD>
                    </TR>
                    <TR>
                        <TD colspan="2" align="center">
                            <INPUT TYPE="submit" value="<%=produk.getAction()%>" name="action">
                        </TD>
                        <TD>
                            &nbsp;
                        </TD>
                    </TR>
                </TABLE>
            </CENTER>
        </form>
  
</body>
</html>
